home *** CD-ROM | disk | FTP | other *** search
/ Mastering Public Speaking / Mastering Public Speaking.iso / pc / Click Here.exe / Click Here.dxr / Internal_35_Stop Sound.ls < prev    next >
Encoding:
Text File  |  2003-05-13  |  2.4 KB  |  68 lines

  1. property soundChannel, stopWhen
  2.  
  3. on beginSprite me
  4.   if (stopWhen = "at the beginning of the frame") or (stopWhen = "when the sprite first appears") then
  5.     me.stopMySound()
  6.   end if
  7. end
  8.  
  9. on endSprite me
  10.   if (stopWhen = "at the end of the frame") or (stopWhen = "when the sprite leaves the stage") then
  11.     me.stopMySound()
  12.   end if
  13. end
  14.  
  15. on mouseEnter me
  16.   if stopWhen = "when the cursor moves over the sprite" then
  17.     me.stopMySound()
  18.   end if
  19. end
  20.  
  21. on mouseLeave me
  22.   if stopWhen = "when the cursor moves off of the sprite" then
  23.     me.stopMySound()
  24.   end if
  25. end
  26.  
  27. on mouseDown me
  28.   if stopWhen = "when the mouse clicks on the sprite" then
  29.     me.stopMySound()
  30.   end if
  31. end
  32.  
  33. on mouseUp me
  34.   if stopWhen = "when the mouse button is released over the sprite" then
  35.     me.stopMySound()
  36.   end if
  37. end
  38.  
  39. on stopMySound me
  40.   sound(soundChannel).stop()
  41. end
  42.  
  43. on isOKToAttach me, aSpriteType, aSpriteNum
  44.   return 1
  45. end
  46.  
  47. on getPropertyDescriptionList me
  48.   props = [:]
  49.   props[#soundChannel] = [#comment: "Sound channel:", #format: #integer, #default: 1, #range: [1, 2, 3, 4, 5, 6, 7, 8]]
  50.   if the currentSpriteNum = 0 then
  51.     whenDefault = "at the beginning of the frame"
  52.     whenRange = ["at the beginning of the frame", "at the end of the frame"]
  53.   else
  54.     whenDefault = "when the mouse clicks on the sprite"
  55.     whenRange = ["when the sprite first appears", "when the sprite leaves the stage", "when the mouse clicks on the sprite", "when the mouse button is released over the sprite", "when the cursor moves over the sprite", "when the cursor moves off of the sprite"]
  56.   end if
  57.   props[#stopWhen] = [#comment: "When to stop sound:", #format: #symbol, #default: whenDefault, #range: whenRange]
  58.   return props
  59. end
  60.  
  61. on getBehaviorTooltip me
  62.   return "Stops a sound based on a frame or sprite event."
  63. end
  64.  
  65. on getBehaviorDescription me
  66.   return "STOP SOUND" & RETURN & RETURN & "Drop this behavior onto a sprite, the Stage, or the Script channel of the Score to stop a sound based on the movement of the playback head or cursor." & RETURN & RETURN & "When used in the Script channel, this behavior can stop the sound when the playback head enters or leaves the frame. " & "With sprites, the behavior can react to the beginning or end of the sprite, or to mouse events. " & "Choose a sound channel and an event to stop the sound." & RETURN & RETURN & "PARAMETERS:" & RETURN & "* Sound channel - which channel to stop" & RETURN & "* When to stop sound - event to trigger stop"
  67. end
  68.